<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>路由规则</title>
	</head>
	<body>
	<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vue-router.js" type="text/javascript" charset="utf-8"></script>
		<div id="app">
			<!-- 会将这个标签解析为a标签
				to会解析为href
			 -->
			<router-link to="/zoo">动物园</router-link>
			<router-link to="/shopping">商场</router-link>
			<router-link to="/">默认</router-link>
			
			<router-view></router-view>
			
		<h1>路由的规则</h1>
		</div>
	</body>
	<template id="zoo">
		<div id="">
			<h1>我是动物园组件</h1>
		</div>	</template>

	
	<template id="shopping">
		<div id="">
			<h1>我是商场组件</h1>
			<router-link to="/shopping/shoe">鞋店</router-link>
			<router-link to="/shopping/phone">手机店</router-link>
			<router-view> </router-view>
		</div>
	</template>
	<template id="shoe">
		<div id="">
			<h1>我是鞋店组件</h1>
		</div>
	</template>
	
	<template id="phone">
		<div id="">
			<h1>我是手机组件</h1>
		</div>
	</template>
	
	
	<script>
	
	const shopping=	{
		template:"#shopping"
	}
	
	const zoo=	{
		template:"#zoo"
	}
	const shoe={
		template:"#shoe"
	}
	const phone={
		template:"#phone"
	}
	
	const router=new VueRouter({
		routes:[
			{
				path:"/",redirect:"/user"
			},
			{
				path:"/shopping",
				component:shopping,
				children:[
					{path:"/shopping/shoe",component:shoe},
					{path:"/shopping/phone",component:phone}
				]
			},{
				path:"/zoo",
				component:zoo
			}
		]
		
	})
	const appp=new Vue({
		el:app,
		router
	})
	</script>
</html>
